﻿using Microsoft.Practices.Unity;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;
using StockholmsStad.Windows.UI.Infrastructure.Interfaces;
using StockholmsStad.Windows.UI.Modules.MainModule.Interfaces;
using StockholmsStad.Windows.UI.Modules.MainModule.Models;

namespace StockholmsStad.Windows.UI.Modules.MainModule.Services
{
    public class ToolBarService : IToolBarService
    {
        private IApplicationService applicationService;

        [Dependency]
        public IApplicationService ApplicationService
        {
            set { applicationService = value; }
        }

        #region IToolBarService Members

        public ToolBarPresentationModel InitializeModel()
        {
            var model = new ToolBarPresentationModel();

            var user = applicationService.GetCurrentUser();

            if(user != null)
                model.IsVisible = user.Role == UserRole.ReadOnly || user.Role == UserRole.HandlingOfficer ? false : true;
            else
                model.IsVisible = false;
     
            return model;
        }

        #endregion
    }
}
